home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / PDraw3.0.adf / pdraw_rex.lzh / CopyObjectToPages.pdrx < prev    next >
Text File  |  1992-06-22  |  2KB  |  90 lines

  1. /*
  2. @N
  3.  
  4. This Genie will copy an object or group of objects to a range of pages.
  5. */
  6. msg = PDSetup.rexx(2,0)
  7. units = getclip(pds_units)
  8. if msg ~= 1 then exit_msg(msg)
  9.  
  10. arg object, startpage, endpage
  11. pageoptions = "ODDEVENALL "
  12.  
  13. if object = '' then do
  14.  object = pdm_SelFirstobj()
  15.  if object = 0 then
  16.     exit_msg("Select a group of objects to be copied first")
  17.     sourcepage = pdm_GetObjPage(object)
  18.     docstart = pdm_DocFirstPage()
  19.     docend = pdm_DocLastPage()
  20.  
  21.     form = "Start Page:"docstart'0a'x "End Page:"docend'0a'x "ODD/EVEN/ALL:ALL"
  22.     form = upper(pdm_GetForm("Enter options", 8, form))
  23.  if form = '' then exit_msg()
  24.  
  25.     parse var form startpage '0a'x endpage '0a'x pageopts
  26.  
  27.     if endpage = '' then exit_msg("Invalid Range")
  28.     if pageopts = '' then pageopts = "ALL"
  29.  
  30.     if startpage < docstart then exit_msg("Invalid Range")
  31.     else if startpage > docend then exit_msg("Invalid Range")
  32.     if endpage < docstart then exit_msg("Invalid Range")
  33.     else if endpage > docend then exit_msg("Invalid Range")
  34.     if endpage < startpage then exit_msg("Invalid Range")
  35. end
  36.  
  37.  
  38. if datatype(startpage) ~= 'NUM' | datatype(endpage) ~= 'NUM' then
  39.     call exit_msg("Invalid input")
  40.  
  41. if verify(pageopts, pageoptions) ~= 0 then exit_msg("Invalid Entry")
  42.  
  43. opos = pos(pageopts, pageoptions) 
  44.  
  45. if opos = 4 then do
  46.     increment = 2
  47.     if (startpage // 2) then startpage = startpage + 1
  48. end
  49. else if opos = 1 then do
  50.     increment = 2
  51.     if ~(startpage // 2) then startpage = startpage + 1
  52. end
  53. else increment = 1
  54.  
  55. num = 0
  56. object = pdm_SelFirstObj()
  57. do while object ~= 0
  58.    if ((pdm_iscompound(object) = 0) | (pdm_isfirst(object) ~= 0)) then do
  59.    num = num + 1
  60.       objects.num = object
  61.    end
  62.    object = pdm_SelNextObj(object)
  63. end
  64.  
  65. do page = startpage to endpage by increment
  66.    if page ~= sourcepage then do
  67.       call pdm_ShowStatus("Working on page "page)
  68.       do i = 1 to num
  69.          newobject  = pdm_CloneObj(objects.i, 0, 0, 0, 0, 1, 1, 0)
  70.          call pdm_SetObjPage(newobject, page)
  71.       end
  72.    end
  73. end
  74.  
  75. exit_msg()
  76.  
  77. exit_msg: procedure expose units
  78. do
  79.     parse arg message
  80.  
  81.     if message ~= '' then
  82.         call pdm_Inform(1,message,)
  83.  
  84.  call pdm_SetUnits(units)
  85.     call pdm_ClearStatus()
  86.     call pdm_AutoUpdate(1)
  87.     exit
  88. end
  89.